<!-- 模板继承 -->
{extend name="public:base" /}

<!-- 页面标题 -->
{block name="title"}Administrator{/block}

<!-- 自定义css -->
{block name="css"}{/block}

<!-- 内容区域 -->
{block name="content"}
  <div class="nav-tabs-custom">
    <ul class="nav nav-tabs">
      <li class=""><a href="{:url('admin/role/index')}">{:lang('Role')}</a></li>
      <li class=""><a href="{:url('admin/role/create')}">{:lang('Create')}</a></li>
    </ul>

    <div class="tab-content">
        <div class="tab-pane active table-responsive no-padding">
            <table class="table table-condensed table-hover">
                <thead>
                    <tr>
                        <th>{:lang('Site name')}</th>
                        <th class="text-right">{$info.role_name}</th>
                    </tr>
                </thead>
                <tbody>
                    <form id="form">
                    {volist name="list" id="vo"}
                    <tr>
                        <td>{$vo.name}</td>
                        <td class="text-right"><input {in name="vo.id" value="$site"}checked{/in} name="ids[]" value="{$vo.id}" type="checkbox"></td>
                    </tr>
                    {/volist}
                    <input type="hidden" name="role_id" value="{$info.role_id}">
                    </form>
                </tbody>
            </table>
        </div>
        <!-- /.tab-pane -->
    </div>
    <!-- /.tab-content -->
    <div class="box-footer">
        <div class="btn-group">
            <button class="btn btn-primary btn-flat" onclick="siteAuth();" type="button"> {:lang('Save')}</button>
        </div>
    </div>
  </div>
{/block}

<!-- 自定义js -->
{block name="js"}
<script type="text/javascript">
    function siteAuth(){
        $.ajax({
            url:"{:Url('admin/role/siteAuth')}",
            data:$("#form").serialize(),
            type:'post',
            dataType:'json',
            success: function(xhr){
                if(xhr.code == 200){
                    swal(xhr.msg, "","success");
                }else{
                    swal(xhr.msg, "", "error");
                }
            }
        })
    }
</script>
{/block}